Filter Absolute Numbers in array?

Is it possible to build & apply a filter based on Absolute Number values stored in an array absNos[]?
I thought something like below might work but no luck, despite trying various obvious syntax permutations.
 

int absNos[]={1,2,3,5} //normally this is populated via user input
absNosCount=sizeof(absNos)
Filter f=null
int i
for (i=0; i<absNosCount; i++)
{
    int absNo=absNos[i]
    if (f==null)
    {   //seems to not work if not quoted, but can't quote int variable!
        f=(attribute "Absolute Number" == absNo)
    }
    else
    {   //this syntax may not be legal:
        f=f || (attribute "Absolute Number" == absNo)
    }
}

 


Regards,
Strathglass.

 


strathglass - Wed Mar 11 09:08:01 EDT 2009

Re: Filter Absolute Numbers in array?
strathglass - Wed Mar 11 09:13:34 EDT 2009

And by the way, why doesn't the {code} tag work???
-Strathglass

Re: Filter Absolute Numbers in array?
SystemAdmin - Wed Mar 11 09:20:15 EDT 2009

Look at the "reject" (and "accept") functions in DXL Help.

Re: Filter Absolute Numbers in array?
strathglass - Wed Mar 11 09:38:07 EDT 2009

SystemAdmin - Wed Mar 11 09:20:15 EDT 2009
Look at the "reject" (and "accept") functions in DXL Help.

Thanks Pekka - those two did the trick!

Regards,
Strathglass

Re: Filter Absolute Numbers in array?
llandale - Wed Mar 11 10:58:26 EDT 2009

Yes, I've not had much luck applying 'Filter' variables to my filters. Instead, I just plow through all the objects in the entire module, decide if I want this object displayed (in this case, is it in your list), and either 'accept' or 'reject' each object. The framework looks like this:

Module mCurr = current
Object obj
filtering off
for obj in entire mCurr do
{ reject(obj) // by default
...if (isDeleted(obj)) continue // don't show deleted object
...if (row(obj) or table(obj)) continue // cannot show Table or Row headers
...if (cell(obj)) continue // don't show table cells
...if (this object qualifies) then accept(obj)
}
filtering on

Notice there is no 'Filter' variables, nor no 'set(Filter)' commands using this method.

>Louie

Re: Filter Absolute Numbers in array?
Doug.Zawacki - Wed Mar 11 14:37:11 EDT 2009

To answer your original question. Here is the code that should do as you expected. You needed to convert the absNo to a string and then set the filter at the end.

filtering on
int absNos[]={1,2,3,5} //normally this is populated via user input
absNosCount=sizeof(absNos)
Filter f=null
int i
for (i=0; i<absNosCount; i++)
{
int absNo=absNos[i]
if (f==null)
{ //seems to not work if not quoted, but can't quote int variable!
f=(attribute "Absolute Number" == absNo "")
}
else
{ //this syntax may not be legal:
f=f || (attribute "Absolute Number" == absNo "")
}
}
int iAccepted,iRejected
set(current,f,iAccepted,iRejected)

print "Filter =" stringOf(current,f) "\n"
print "Accepted: " iAccepted " -- Rejected: " iRejected "\n"

Re: Filter Absolute Numbers in array?
strathglass - Thu Mar 12 07:55:10 EDT 2009

Doug.Zawacki - Wed Mar 11 14:37:11 EDT 2009
To answer your original question. Here is the code that should do as you expected. You needed to convert the absNo to a string and then set the filter at the end.

filtering on
int absNos[]={1,2,3,5} //normally this is populated via user input
absNosCount=sizeof(absNos)
Filter f=null
int i
for (i=0; i<absNosCount; i++)
{
int absNo=absNos[i]
if (f==null)
{ //seems to not work if not quoted, but can't quote int variable!
f=(attribute "Absolute Number" == absNo "")
}
else
{ //this syntax may not be legal:
f=f || (attribute "Absolute Number" == absNo "")
}
}
int iAccepted,iRejected
set(current,f,iAccepted,iRejected)

print "Filter =" stringOf(current,f) "\n"
print "Accepted: " iAccepted " -- Rejected: " iRejected "\n"

Hey - nice trick Doug. Thanks for that.
I realize I forgot the set() call in my example.
But I didn't realize I simply had to cast my integer to string to successfully build my filter string.
Thanks again!

And thanks Louie too - that is how I ended up coding it per Pekka's input too, before I saw Doug's response.

Regard,
Strathglass.

Re: Filter Absolute Numbers in array?
strathglass - Thu Mar 26 09:55:43 EDT 2009

Doug.Zawacki - Wed Mar 11 14:37:11 EDT 2009
To answer your original question. Here is the code that should do as you expected. You needed to convert the absNo to a string and then set the filter at the end.

filtering on
int absNos[]={1,2,3,5} //normally this is populated via user input
absNosCount=sizeof(absNos)
Filter f=null
int i
for (i=0; i<absNosCount; i++)
{
int absNo=absNos[i]
if (f==null)
{ //seems to not work if not quoted, but can't quote int variable!
f=(attribute "Absolute Number" == absNo "")
}
else
{ //this syntax may not be legal:
f=f || (attribute "Absolute Number" == absNo "")
}
}
int iAccepted,iRejected
set(current,f,iAccepted,iRejected)

print "Filter =" stringOf(current,f) "\n"
print "Accepted: " iAccepted " -- Rejected: " iRejected "\n"

Just learned one other important advantage of Doug's method:

If you just use accept and reject, you can filter as desired.
But this does not affect the filter functions current filter list:
so if you try to save your filtering done with accept and reject in a view it will not work:
the filtering is NOT saved (at least,not the filtering you did using accept/reject).

However with Doug's approach, the filter is a normal filter added to the filter function as the current filter:
this CAN be saved in a view!

Regards, strathglass

Re: Filter Absolute Numbers in array?
dpechacek - Wed Sep 23 17:18:10 EDT 2009

strathglass - Thu Mar 26 09:55:43 EDT 2009
Just learned one other important advantage of Doug's method:

If you just use accept and reject, you can filter as desired.
But this does not affect the filter functions current filter list:
so if you try to save your filtering done with accept and reject in a view it will not work:
the filtering is NOT saved (at least,not the filtering you did using accept/reject).

However with Doug's approach, the filter is a normal filter added to the filter function as the current filter:
this CAN be saved in a view!

Regards, strathglass

Hey guys. I'm trying to do this kind of filter. Getting a problem. Here's the code.
 

Object o;
      Filter f = null;
      Filter temp;
      Buffer objID = create();
      int absNum;
   
      for o in problemObjects do {
         objID = (string key(problemObjects));
         objID = objID[(contains(objID, '-')+1):];
         absNum = intOf(tempStringOf(objID));
         
         if(null(f)) {
            f = attribute "Absolute Number"  == absNum "";
         }
         else {
            f = f || attribute "Absolute Number"  == absNum "";
         } 
      }
      
      print stringOf(current, f) "\n";
      int accepted, rejected
      
      set(currentMod, f, accepted, rejected);
      filtering(on);
      refresh(currentMod);
      
      print accepted "\n"
      print rejected "\n"
      
      delete(objID);
      objID = null;

 


Now the code runs. Its just not applying the filter. I know its setting it because I can go turn on filtering manually and its the proper filter as well as the prints of accepted/rejected objects work. But its just not turning on filtering as it should be. Anyone see the problem?

AAI Services, Textron
dpechacek@aai.textron.com
David.Pechacek@gmail.com

 

Re: Filter Absolute Numbers in array?
llandale - Wed Sep 23 19:16:49 EDT 2009

dpechacek - Wed Sep 23 17:18:10 EDT 2009

Hey guys. I'm trying to do this kind of filter. Getting a problem. Here's the code.
 

Object o;
      Filter f = null;
      Filter temp;
      Buffer objID = create();
      int absNum;
   
      for o in problemObjects do {
         objID = (string key(problemObjects));
         objID = objID[(contains(objID, '-')+1):];
         absNum = intOf(tempStringOf(objID));
         
         if(null(f)) {
            f = attribute "Absolute Number"  == absNum "";
         }
         else {
            f = f || attribute "Absolute Number"  == absNum "";
         } 
      }
      
      print stringOf(current, f) "\n";
      int accepted, rejected
      
      set(currentMod, f, accepted, rejected);
      filtering(on);
      refresh(currentMod);
      
      print accepted "\n"
      print rejected "\n"
      
      delete(objID);
      objID = null;

 


Now the code runs. Its just not applying the filter. I know its setting it because I can go turn on filtering manually and its the proper filter as well as the prints of accepted/rejected objects work. But its just not turning on filtering as it should be. Anyone see the problem?

AAI Services, Textron
dpechacek@aai.textron.com
David.Pechacek@gmail.com

 

Its working for me when I manually set your Skip problemObjects. My guess is that your 'currentMod' is no longer your current module, for whatever reason. If so, you are turning 'filtering(on)' on some other module, probably the one you opened to find your 'problemObjects'. Check it out: add

print "Current Module before filter = [" name(current Module) "]\n"


before your filtering(on) statement. You will perhaps need to "current = currentMod" before the filtering(on) statement.

I admit I'm surprised you don't need some form of 'filtering(off)' to get this going; but lets hope you do that when finding your problemObjects.

 

 

  • Louie

 

 

Re: Filter Absolute Numbers in array?
dpechacek - Thu Sep 24 10:28:20 EDT 2009

llandale - Wed Sep 23 19:16:49 EDT 2009

Its working for me when I manually set your Skip problemObjects. My guess is that your 'currentMod' is no longer your current module, for whatever reason. If so, you are turning 'filtering(on)' on some other module, probably the one you opened to find your 'problemObjects'. Check it out: add

print "Current Module before filter = [" name(current Module) "]\n"


before your filtering(on) statement. You will perhaps need to "current = currentMod" before the filtering(on) statement.

I admit I'm surprised you don't need some form of 'filtering(off)' to get this going; but lets hope you do that when finding your problemObjects.

 

 

  • Louie

 

 

Good point Louie. But yeah this is just a piece of a larger script.

AAI Services, Textron
dpechacek@aai.textron.com
David.Pechacek@gmail.com